import 'package:dio/dio.dart' hide Headers;
import 'package:retrofit/retrofit.dart';
import 'package:tin_flutter/ui/bean/base_response_entity.dart';
import 'package:tin_flutter/ui/bean/response/brand_product_entity.dart';
import 'package:tin_flutter/ui/bean/response/home_content_entity.dart';
import 'package:tin_flutter/ui/bean/response/login_response_entity.dart';
import 'package:tin_flutter/ui/bean/response/recommend_product_entity.dart';

import '../app_constant.dart';

part 'retrofit_client.g.dart';

@RestApi(baseUrl: AppConstant.base_url, parser: Parser.JsonSerializable)
abstract class RetrofitClient {
  factory RetrofitClient(Dio dio, {String? baseUrl}) = _RetrofitClient;

  /// 登录接口
  /// * [encryptedData] 加密数据
  @POST('v1/login')
  Future<BaseResponseEntity<LoginResponseEntity>> login(
      @Field('encryptedData') String encryptedData);

  /// 获取首页内容
  @GET('home/content')
  Future<BaseResponseEntity<HomeContentEntity>> getHomeContent();

  /// 分页获取推荐列表
  /// * [page] 页码
  /// * [size] 每页数量
  @GET('home/recommendProductList')
  Future<BaseResponseEntity<List<RecommendProductEntity>>> getRecommendProductList(
      @Query('pageNum') int page, @Query('pageSize') int size);

  /// 分页获取品牌推荐列表
  /// * [page] 页码
  /// * [size] 每页数量
  @GET('brand/recommendList')
  Future<BaseResponseEntity<List<HomeContentBrandList>>> getRecommendBrandList(
      @Query('pageNum') int page, @Query('pageSize') int size);

  /// 获取品牌详情
  /// * [brandId] 品牌ID
  @GET('brand/detail/{brandId}')
  Future<BaseResponseEntity<HomeContentBrandList>> getBrandDetail(
      @Path('brandId') int brandId);

  /// 分页获取品牌商品列表
  /// * [brandId] 品牌ID
  /// * [page] 页码
  /// * [size] 每页数量
  @GET('brand/productList')
  Future<BaseResponseEntity<BrandProductEntity>> getBrandProductList(
      @Query('brandId') int brandId,@Query('pageNum') int page, @Query('pageSize') int size);
}
